import { defineComponent as M, ref as C, watch as T, computed as U, resolveComponent as r, resolveDirective as x, openBlock as n, createElementBlock as i, Fragment as v, withDirectives as F, createBlock as g, mergeProps as H, withCtx as k, renderList as J, createVNode as h, createElementVNode as O, createCommentVNode as u, renderSlot as y, resolveDynamicComponent as b, unref as _, toDisplayString as Z, normalizeStyle as q } from "vue";
const S = (t) => t.replace(/([A-Z])/g, "-$1").toLowerCase(), G = {
  key: 0,
  style: { display: "flex", "align-items": "center" }
}, K = {
  key: 1,
  class: "icons"
}, Q = { key: 1 }, R = /* @__PURE__ */ M({
  __name: "index",
  props: {
    options: { default: () => [] },
    data: { default: () => [] },
    loading: { type: Boolean },
    loadingText: { default: "加载中..." },
    loadingSpinner: { default: "spinner" },
    loadingBackground: { default: "rgba(0, 0, 0,.8)" },
    loadingSvg: { default: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      ` },
    loadingSvgViewBox: { default: "0 0 48 48" },
    saveIcon: { default: "Check" },
    cancelIcon: { default: "Close" },
    currentPage: { default: 1 },
    pageSizes: { default: () => [10, 20, 30, 40] },
    pageSize: { default: 10 },
    total: { default: 0 },
    disabled: { type: Boolean, default: !1 },
    small: { type: Boolean, default: !1 },
    background: { type: Boolean, default: !0 },
    pagination: { type: Boolean, default: !0 },
    paginationAlign: { default: "center" }
  },
  emits: ["saveCell", "cancelCell", "handleSizeChange", "handlePageChange"],
  setup(t, { emit: p }) {
    const o = t, d = p, c = C(o.loading || !1);
    T(
      () => o.loading,
      () => {
        c.value = o.loading;
      }
    );
    const m = C(""), w = (e) => {
      m.value = e.$index + "-" + e.column.id;
    }, z = (e) => {
      d("saveCell", e);
    }, $ = (e) => {
      d("cancelCell", e);
    }, B = (e) => {
      d("handleSizeChange", e);
    }, V = (e) => {
      d("handlePageChange", e);
    }, A = U(() => o.paginationAlign === "right" ? "flex-end" : o.paginationAlign === "left" ? "flex-start" : "center");
    return (e, f) => {
      const L = r("el-input"), I = r("el-icon-edit"), P = r("el-table-column"), D = r("el-table"), N = r("el-pagination"), j = x("loading");
      return n(), i(
        v,
        null,
        [
          F((n(), g(D, H(e.$attrs, {
            data: e.data,
            "element-loading-text": e.loadingText,
            "element-loading-spinner": e.loadingSvg,
            "element-loading-svg-view-box": e.loadingSvgViewBox,
            "element-loading-background": e.loadingBackground
          }), {
            default: k(() => [
              (n(!0), i(
                v,
                null,
                J(e.options, (a, E) => (n(), g(P, {
                  key: E,
                  label: a.label,
                  align: a.align,
                  width: a.width
                }, {
                  default: k((l) => [
                    l.$index + "-" + l.column.id == m.value ? (n(), i("div", G, [
                      h(L, {
                        size: "small",
                        modelValue: l.row[a.prop],
                        "onUpdate:modelValue": (s) => l.row[a.prop] = s,
                        placeholder: ""
                      }, null, 8, ["modelValue", "onUpdate:modelValue"]),
                      O("div", {
                        onClick: f[0] || (f[0] = (s) => m.value = "")
                      }, [
                        u(" 自定义图标 "),
                        e.$slots.eidtCell ? y(e.$slots, "eidtCell", {
                          key: 0,
                          scope: l
                        }, void 0, !0) : (n(), i("div", K, [
                          u(" 确定图标 "),
                          (n(), g(b(`el-icon${_(S)(e.saveIcon)}`), {
                            class: "check",
                            onClick: (s) => z(l)
                          }, null, 8, ["onClick"])),
                          u(" 关闭图标 "),
                          (n(), g(b(`el-icon${_(S)(e.cancelIcon)}`), {
                            class: "close",
                            onClick: (s) => $(l)
                          }, null, 8, ["onClick"]))
                        ]))
                      ])
                    ])) : (n(), i(
                      v,
                      { key: 1 },
                      [
                        a.slot ? y(e.$slots, a.slot, {
                          key: 0,
                          scope: l
                        }, void 0, !0) : (n(), i(
                          "span",
                          Q,
                          Z(l.row[a.prop]),
                          1
                          /* TEXT */
                        )),
                        a.edit ? (n(), g(I, {
                          key: 2,
                          class: "edit",
                          onClick: (s) => w(l)
                        }, null, 8, ["onClick"])) : u("v-if", !0)
                      ],
                      64
                      /* STABLE_FRAGMENT */
                    ))
                  ]),
                  _: 2
                  /* DYNAMIC */
                }, 1032, ["label", "align", "width"]))),
                128
                /* KEYED_FRAGMENT */
              ))
            ]),
            _: 3
            /* FORWARDED */
          }, 16, ["data", "element-loading-text", "element-loading-spinner", "element-loading-svg-view-box", "element-loading-background"])), [
            [j, c.value]
          ]),
          e.pagination ? (n(), i(
            "div",
            {
              key: 0,
              class: "pagination",
              style: q({ justifyContent: A.value })
            },
            [
              h(N, {
                "current-page": e.currentPage,
                "page-size": e.pageSize,
                "page-sizes": e.pageSizes,
                small: e.small,
                disabled: e.disabled,
                background: e.background,
                layout: "total, sizes, prev, pager, next, jumper",
                total: e.total,
                onSizeChange: B,
                onCurrentChange: V
              }, null, 8, ["current-page", "page-size", "page-sizes", "small", "disabled", "background", "total"])
            ],
            4
            /* STYLE */
          )) : u("v-if", !0)
        ],
        64
        /* STABLE_FRAGMENT */
      );
    };
  }
}), W = (t, p) => {
  const o = t.__vccOpts || t;
  for (const [d, c] of p)
    o[d] = c;
  return o;
}, X = /* @__PURE__ */ W(R, [["__scopeId", "data-v-7835e216"]]), ee = {
  install(t) {
    t.component("m-table", X);
  }
};
export {
  ee as default
};
